<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>The Oracle JDeveloper IDE</title>
<link rel="stylesheet" href="../format.css" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="keywords" content="Oracle, JDeveloper, Java, Swing">
<meta name="description" content="Introducing Oracle JDeveloper IDE">
<meta name="language" content="en">
<meta name="author" content="Jan Bodnar">
<meta name="distribution" content="global">

</head>

<body>



<div class="content">

<a href="/" title="Home">Home</a>


<h1>The Oracle JDeveloper IDE</h1>

<p>
Java developers  can choose among several different 
IDEs. (Integrated Development Environment)
</p>

<ul>
<li>Eclipse</li>
<li>Netbeans</li>
<li>JDeveloper</li>
<li>JCreator</li>
<li>IntelliJIDEA</li>
</ul>

<div class="center">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<p>
Eclipse and Netbeans are open source software. 
Each IDE has it's strengths and weaknesses.
There is IBM behind Eclipse, Sun behind Netbeans and Oracle behind JDeveloper. 
In this article we will examine JDeveloper. 
The JDeveloper enables you to develop Java enterprise applications as well 
as desktop applications. There are two things that I love about JDeveloper. 
It is it's <b>look and feel</b>. It is the best looking IDE. It is written in 
Swing toolkit. Looks exactly the same on both Windows and Linux. It is slower 
than Eclipse, but it is quite swift. At least for my test development. 
(I have not used it extensively.) The other thing that I like is that it comes 
in <b>three different editions</b>. The studio edition, the j2ee edition and 
the java edition. The basic java edition contains only the core Java and XML 
features. This was exactly what I needed. Why install features you will never use? 
The size of the download is smaller (currently 55 MB) and the application is more responsive. 
</p>

<h2>Installation</h2>

<p>
First we download the JDeveloper IDE from the official download 
<a href="http://www.oracle.com/technology/products/jdev/index.html">page</a>. We must 
go through registration process to access the download file. It is a bit annoying. 
Especially, when you want to uprade your version and you have forgotten your password 
or login. (or both). I am lost in all those logins and passwords. At home, at work, on the web. 
The current version is 10.1.3.2. It was realesed in January 2007. 
I have downloaded the basic java edition. It is perfect for my development of small 
desktop applications in Java and Swing. There are also three install types. Windows,
 Mac and universal base install. I work on linux, so I have chosen the base install. 
It works on all platforms. The other two are probably optimized for those two plaforms. I assume.
The dowload file name is <i>jdevjavabase10132.zip</i>.
<br>
We unzip the file to our preferred directory. Let's say ~/jdeveloper.
<!--Before we launch JDeveloper, we can specify our own user directory for JDeveloper. It is a place where JDeveloper 
stores it's settings and the default mywork directory, where the IDE stores the project directories.-->
Now we can lauch the JDeveloper IDE. The startup file is in the ~/jdeveloper/jdev/bin directory.
</p>

<pre class="code">
./jdev
</pre>

<p>
When we first launch the JDeveloper, it will ask for the path to the Java jdk directory.
<br>
<i>Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.jdev_jdk</i>
</p>

<p>
On my system it is <i>/home/vronskij/bin/jdk1.6.0_01</i>. The path will be stored in the hidden 
<i>.jdev_jdk</i> file name located in the home directory. 
Then we should see this splashscreen.
</p>

<br>
<img src="../images/jdevscreen.png" alt="JDeveloper splashscreen">
<br>

<p>
Whoops. A dialog window pops up.
</p>

<br>
<img src="../images/jdevjava.png" alt="">
<br>

<p>
The problem is that I have the newest Java jdk1.6. And the JDeveloper is 
certified to run on the previous one. I have never encountered any problems 
regarding this issue. And there is a certain progress from the previous 
version of JDeveloper. We can grab the dialog box from behind the splashscreen. 
And click the skip message option.
</p>

<p>
Now we have been rewarded for our patience and hard work and we have the JDeveloper in full beauty. 
Ok. One more step. Close the Tip of the day dialog box. And do not forget to unclick the Show tips on startup box.
Here we have a screenshot of our beautiful Oracle JDeveloper IDE version 10.1.3.2.0.
</p>
<br>
<img src="../images/jdeveloper.png" alt="The Oracle JDeveloper screenshot">
<div class="figure">Oracle JDeveloper IDE</div>
<br>

<h2>Creating a Swing application</h2>

<p>
I like this JDeveloper slim release, because the creation process is quite simple. 
(On the other hand,  it could be even simpler.) Comparing to other IDE's it is.
We do not have to go through all those enterprise apps, beans, libs and the like.
We go to File menu, click New. Then we select Application. We give an application 
a name. In the next dialog window, we provide a name for a project that will 
host our application. We then go to the System Navigator. Select the project. 
Right click on the project name, select New Class. 
We are ready to start coding our Java Swing application.
</p>

<pre class="code">
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;

import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class Puzzle extends JFrame implements ActionListener {

    private JPanel centerPanel;
    private JButton button;
    private JLabel label;
    private Image source;
    private Image image;
    int[][] pos;

    public Puzzle() {

        pos = new int[][] {
                            {0, 1, 2}, 
                            {3, 4, 5}, 
                            {6, 7, 8}, 
                            {9, 10, 11}
                        };


        centerPanel = new JPanel();
        centerPanel.setLayout(new GridLayout(4, 4, 0, 0));

        ImageIcon sid = new ImageIcon(Puzzle.class.getResource("icesid.jpg"));
        source = sid.getImage();


        add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.NORTH);    
        add(centerPanel, BorderLayout.CENTER);


        for ( int i = 0; i < 4; i++) {

            for ( int j = 0; j < 3; j++) {

                if ( j == 2 &amp;&amp; i == 3) {
                    label = new JLabel("");
                    centerPanel.add(label);

                } else {

                    button = new JButton();
                    button.addActionListener(this);
                    centerPanel.add(button);
                    image = createImage(new FilteredImageSource(source.getSource(),
                        new CropImageFilter(j*103, i*60, 103, 60)));
                    button.setIcon(new ImageIcon(image));
                }
            }
        }

        setSize(325, 275);
        setTitle("Puzzle");
        setResizable(false);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setVisible(true);
    }


    public static void main(String[] args) {

        new Puzzle();

    }

    public void actionPerformed(ActionEvent e) {
        JButton button = (JButton) e.getSource();
        Dimension size = button.getSize();

        int labelX = label.getX();
        int labelY = label.getY();
        int buttonX = button.getX();
        int buttonY = button.getY();
        int buttonPosX = buttonX / size.width;
        int buttonPosY = buttonY / size.height;
        int buttonIndex = pos[buttonPosY][buttonPosX];



        if (labelX == buttonX &amp;&amp; (labelY - buttonY) == size.height ) {

             int labelIndex = buttonIndex + 3;

             centerPanel.remove(buttonIndex);
             centerPanel.add(label, buttonIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.validate();
        }

        if (labelX == buttonX &amp;&amp; (labelY - buttonY) == -size.height ) {

             int labelIndex = buttonIndex - 3;
             centerPanel.remove(labelIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.add(label, buttonIndex);
             centerPanel.validate();
        }

        if (labelY == buttonY &amp;&amp; (labelX - buttonX) == size.width ) {

             int labelIndex = buttonIndex + 1;

             centerPanel.remove(buttonIndex);
             centerPanel.add(label, buttonIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.validate();
        }

        if (labelY == buttonY &amp;&amp; (labelX - buttonX) == -size.width ) {

             int labelIndex = buttonIndex - 1;

             centerPanel.remove(buttonIndex);
             centerPanel.add(label, labelIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.validate();
        }
    }
}
</pre>

<p>
We have used a 308 x 238px image of Sid. Sid is one of the main characters in the Ice Age movie. 
</p>

<div class="center">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<br>


<div class="footer">

<div class="signature">
<a href="/">ZetCode::</a> last modified July 10, 2008 <span class="copyright">&copy; 2007 - 2012 Jan Bodnar</span>
</div>

</div>

</div> <!-- content -->

</body>
</html>

